package com.kaishengit.web;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.kaishengit.service.ContactService;

public class NewContact extends HttpServlet {

	private static final long serialVersionUID = 1L;
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.getRequestDispatcher("WEB-INF/views/newcontact.jsp").forward(request, response);
	}
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		HttpSession session = request.getSession();
		String projectid = (String)session.getAttribute("pid");
		String name = request.getParameter("name");
		String companyname = request.getParameter("companyname");
		String mobile = request.getParameter("mobile");
		String tel = request.getParameter("tel");
		String email = request.getParameter("email");
		String address = request.getParameter("address");
		String website = request.getParameter("website");
		String weibo = request.getParameter("weibo");
		String content = request.getParameter("content");
		
		new ContactService().save(name,companyname,mobile,tel,email,address,website,weibo,content,projectid);
		response.sendRedirect("contact.jspx");
	}

}
